package com.thinkingcoder.tcmq.core.model;

import java.util.List;

import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * Result for MQServer.
 * 
 */
@Data
@AllArgsConstructor
public class Result<T> {
    private int code; // 0: failed, 1: success
    private T data;

    public static Result<String> ok() {
        return ok("OK");
    }

    public static Result<String> ok(String message) {
        return new Result<>(1, message);
    }

    public static Result<Message<?>> message(String message) {
        return new Result<>(1, Message.create(message, null));
    }

    public static Result<Message<?>> message(Message<?> message) {
        return new Result<>(1, message);
    }

    public static Result<List<Message<?>>> message(List<Message<?>> message) {
        return new Result<>(1, message);
    }

    public static Result<Stat> stat(Stat stat) {
        return new Result<>(1, stat);
    }
}
